home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / misc / clc171.zip / TUTOR.BAT < prev   
DOS Batch File  |  1995-01-22  |  6KB  |  145 lines

  1. @echo off
  2. cls
  3. echo ======== Introductory tutorial to Q calculator =========
  4. echo.
  5. echo This tutorial batch file will run Q with various examples.  
  6. echo During the run of the tutor.bat,  files "A" and "C" are generated.
  7. echo Also, the tutorial uses a data file "B".
  8. echo Press any key when prompt to do so and the tutorial will guide you
  9. echo through the basic steps.
  10. echo.
  11. echo Let's start with the simplest calculation. To calculate 2+3 use: q 2+3
  12. echo Note that every line starts with q which is the program's name.
  13. pause
  14. echo q 2+3
  15. q 2+3
  16. echo To compute 2(3+4pi)5 where pi is the constant 3.14... type: q 2(3+4pi)5
  17. pause
  18. echo q 2(3+4pi)5
  19. q 2(3+4pi)5
  20. echo To obtain a table of x^3 with x from 0 to 100 write: q x^3 
  21. echo Using "more" will show one page at a time.
  22. pause
  23. @echo on
  24. q x^3 | more
  25. @echo off
  26. echo Substitution is simple. For example Jack=4; Jim=6; Jack+Jim; Jack-Jim
  27. echo will result in ...
  28. pause
  29. echo q Jack=4; Jim=6;  Jack+Jim;  Jack-Jim
  30. q Jack=4;  Jim=6;  Jack+Jim;  Jack-Jim
  31. echo To solve an equation with x as unknown just write it. 
  32. echo Sometimes you should use rng() to redefine the range of x in which to look 
  33. echo for a solution. For example  rng(-10,10)2x+x^3=1/3
  34. echo If there is more than one solution - the program will always display 
  35. echo the smallest solution in the range. 
  36. echo If you don't use rng, the range is 0 to 100.
  37. pause
  38. echo q rng(-10,10)2x+x^3=1/3
  39. q rng(-10,10)2x+x^3=1/3
  40. echo To write into a file use greater then sign. Let's examine the expression
  41. echo q rng(0,360)sin(dr(x));cos(dr(x))
  42. echo here sine and cosine functions are calculated. 
  43. echo x is in degrees from 0 to 360 deg (defined by rng().
  44. echo note that dr transfers x from degrees to radians. We have to use dr() 
  45. echo because the sine and cosine accept only radians.
  46. echo A semicolon ; is used to separate expressions. To write the resulting
  47. echo table to a file "A" add the greater-then sign and A as in the following 
  48. pause
  49. @echo on
  50. q dr(x);rng(0,360)sin(dr(x));cos(dr(x)) > a
  51. @echo off
  52. echo DONE!
  53. echo You may use \DOS\EDIT to see the file "a". 
  54. echo Don't forget to press ALT-f, x to exit when you are done.
  55. echo The 1st column are the radians, in the 2nd the sine and in 
  56. echo the 3rd cosine. 
  57. pause
  58. echo \dos\edit a.
  59. \dos\edit a.
  60. echo.
  61. echo To see the sine column in file "a" as a function of the x column 
  62. echo type: q g~a
  63. echo This will display the second column as a function of the first.
  64. echo Note: when done watching a graph press any key to continue.
  65. pause
  66. q g~a
  67. echo To display the 3rd column as a function of the 2nd skip a column 
  68. echo using one / and type q g~/a. A circle will result.
  69. pause
  70. q g~/a
  71. echo to see just the cosine (column 3) in file "a" type y~//a, 
  72. echo this will display the 3rd column as a function of the index.
  73. pause
  74. q y~//a
  75. echo q 2x*y~/a will of course result in a table where y is obtained from 
  76. echo column 2, x runs from 0 to 100.
  77. pause
  78. echo q 2x*y~/a
  79. q 2x*y~/a
  80. echo To display a function use grf(). For example, to see the 
  81. echo log of x, x running from 0.00001 to 1 type q rng(0.0001,1)grf(log(x)):
  82. pause
  83. q rng(0.00001,1)grf(log(x))
  84. echo To do statistics with data from a file use s~file-name. As an example
  85. echo we prepared the file b. We shall use "type b" to see it's contents.
  86. pause
  87. type b
  88. echo The first 2 lines are always ignored by the program and may be used
  89. echo as headers. To do statistics on the 2nd column use: q s~/b
  90. pause
  91. echo s~/b
  92. q s~/b
  93. echo To see the high correlation between column 3 (gym) and column 4 (history)
  94. echo we use q s~//b
  95. pause
  96. q s~//b
  97. echo r is a random variable in the range 0 to 1. We can use r to simulate a
  98. echo noisy sine wave. q grf(sin(x/10)+0.3(0.5-r)) will do. 
  99. pause
  100. q grf(sin(x/10)+0.3(0.5-r))
  101. echo Q provides for change of base (2-36) and bitwise operations.
  102. echo To read a number in a base n add [n] in from of that number.
  103. echo To display a result in a specific base n, add [n] at the end of the 
  104. echo expression. For example, [2]10001001000100100110101[16] will convert
  105. echo from binary to hex bases.
  106. pause 
  107. echo q [2]10001001000100100110101[16]
  108. q [2]10001001000100100110101[16]
  109. echo to read data in a different base n from a file add [n] in front of the
  110. echo file-name.
  111. echo Let's prepare a binary file and read it later.
  112. echo The following expression i;2x^3[2] will write the indexed table
  113. echo into file C provided we use the greater than sign in front of "C".
  114. pause 
  115. @echo on
  116. q i;2x^3[2] > c
  117. @echo off
  118. echo DONE!
  119. echo Let's call \DOS\EDIT to see how it looks like.
  120. pause
  121. echo \dos\edit c
  122. \dos\edit c
  123. echo Now let's use it in a graph. grf(y)~/[2]c will read the data in the 2nd
  124. echo column and plot. The program will read up to 32 bit numbers from a file.
  125. pause
  126. q grf(y)~/[2]c
  127. echo Bitwise operators may be put into [] to prevent confusion.
  128. echo For example [2]100100010001000 [_and] [2]100101010[2] will perform 
  129. echo bitwise AND and display the result in binary format.
  130. pause
  131. echo q [2]100100010001000 [_and] [2]100101010[2]
  132. q [2]100100010001000 [_and] [2]100101010[2]
  133. echo You can test logical expressions. The convention is that 0 is FALSE
  134. echo and anything else is TRUE.
  135. echo For example: not( (2 GT 1) and ( 3 [EQ] 7 ) ) should result with 1. 
  136. echo We used [] otherwise the E in EQ is confused with an exponent.
  137. pause
  138. echo not( (2 gt 1) and ( 3 [eq] 7 ) )
  139. q not( (2 gt 1) and ( 3 [eq] 7 ) )
  140. echo.
  141. echo This concludes our little tour.
  142. echo To find more about the Q calculator run it and read the help screens. 
  143. echo Enjoy.
  144.  
  145.